package rocketmq.demo.trans.person;

import java.util.Date;

import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.common.message.Message;

import rocketmq.demo.utils.SerializeUtil;

public class Producer {
	public static void main(String[] args) throws Exception {
		DefaultMQProducer producer = new DefaultMQProducer("testGroup3");
		// 指定nameServer的地址 （测试时在代码中指定）
		producer.setNamesrvAddr("127.0.0.1:9876");
		producer.start();
		producer.setRetryTimesWhenSendAsyncFailed(0);
		for (int i = 0; i < 5; i++) {
			final int index = i;
			Person person = new Person(index, "name", new Date());
			Message msg = new Message("Persions", "testTag", "keys", SerializeUtil.serialize(person));
			producer.send(msg);
		}
		producer.shutdown();
	}
}